<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>听我说</title>
    <!-- <link rel="stylesheet" type="text/css" href="bootstrap.min.css"> -->
    <style type="text/css">
        body {
            padding: 0;
            margin: 0;
            overflow: hidden;
        }

        body {
            overflow: hidden;
            position: fixed;
            background: #f9c8c4;
        }

        /*button {*/
        /*    margin: 10px;*/
        /*}*/

        .record {
            position: absolute;
            top: 900px;
            margin-left: 50px;
            width: 400px;
            height: 400px;
            /*background-image: url('img/4.png');*/
            /*background-size: cover;*/
            /*background-repeat: no-repeat;*/
            border-radius: 50%;
            /*animation: rotate 3s linear infinite;*/
            /*animation-play-state: paused; !* 设置初始状态为暂停 *!*/
        }
        .rotate-container {
            width: 100%;
            height: 100%;
            background-image: url('img/4.png');
            background-size: cover;
            background-repeat: no-repeat;
            animation: rotate 3s linear infinite;
            animation-play-state: paused;
            transform-origin: center;
            /*pointer-events: none;*/
        }
        #rotateRecord {
            transform-origin: center; /* 设置旋转的原点为元素中心 */
        }


        .reservation {
            width: 850px;
        }

        .bin {
            width: 350px;
            height: 350px;
            position: absolute;
            top: 1090px;
            margin-left: 380px;
        }

        .p1 {
            width: 850px;
        }

        .p2 {
            width: 850px;
        }

        .p3 {
            width: 380px;
        }

        #pay1 {
            position: absolute;
            top: 50%; /* 将按钮的顶部与父容器的中心对齐 */
            left: 50%; /* 将按钮的左侧与父容器的中心对齐 */
            transform: translate(-50%, -50%);
            height: 80px;
            width: 80px;
            font-size: 30px;
            /*position: absolute;*/
            /*left: 600px;*/
            /*top: 500px;*/
        }

        @keyframes rotate {
            from {
                transform: rotate(0deg);
            }
            to {
                transform: rotate(360deg);
            }
        }

        @media screen and (max-width: 750px) {
            .p1 {
                width: 750px;
            }

            .p2 {
                width: 750px;
            }

            .p3 {
                position: absolute;
                width: 350px;
                margin-top: -100px;
            }

            .record {
                margin-top: -100px;
            }

            #pay1 {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                /*left: 400px;*/
                /*top: 500px;*/
            }
        }

        @media screen and (max-width: 640px) {
            .p1 {
                width: 640px;
            }

            .p2 {
                width: 640px;
            }

            .p3 {
                position: absolute;
                width: 240px;
                margin-top: -250px;
            }

            .record {
                margin-top: -230px;
            }
        }

        @media screen and (max-width: 540px) {
            .p1 {
                width: 540px;
            }

            .p2 {
                width: 540px;
            }

            #pay1 {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);

                /*left:300px;top:500px;*/
            }

            .p3 {
                position: absolute;
                width: 160px;
                margin-top: -400px;
                margin-left: -70px;
            }

            .record {
                width: 300px;
                height: 300px;
                margin-top: -300px;
            }
        }

        @media screen and (max-width: 475px) {
            .p1 {
                width: 475px;
            }

            .reservation {
                width: 475px;
            }

            .p2 {
                width: 475px;
            }

            #pay1 {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                /*left: 320px;*/
                /*top: 480px;*/
            }

            .p3 {
                position: absolute;
                width: 160px;
                margin-top: -500px;
                margin-left: -100px;
            }

            .record {
                width: 280px;
                height: 280px;
                margin-top: -400px;
            }
        }

        @media screen and (max-width: 415px) {
            .p1 {
                width: 415px;
            }

            .reservation {
                width: 415px;
                overflow: hidden;
            }

            #pay1 {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                /*left: 240px;*/
                /*top: 430px;*/
            }

            .p2 {
                width: 415px;
            }

            .p3 {
                position: absolute;
                width: 160px;
                margin-top: -580px;
                margin-left: -175px;
            }

            .record {
                width: 200px;
                height: 200px;
                margin-top: -470px;
                margin-left: 30px;
            }
        }

        @media screen and (max-width: 375px) {
            .p1 {
                width: 375px;
            }

            .reservation {
                width: 375px;
                overflow: hidden;
            }

            .p2 {
                width: 375px;
            }

            .p3 {
                position: absolute;
                width: 160px;
                margin-top: -600px;
                margin-left: -200px;
            }

            .record {
                width: 190px;
                height: 190px;
                margin-top: -500px;
                margin-left: 30px;
            }

            body {
                padding: 0;
                margin: 0;
                width: 375px;
                overflow: hidden;
            }
        }
    </style>
</head>
<body>
<div class="container-full">
    <div class="reservation" style="margin:0 auto">
        <img class="p1" src="img/6.png"/>
        <img class="p2" src="images/b5.png"/>
        <div class="record">
            <div id="rotateRecord" class="rotate-container"></div>
                <button id="pay1" style="background: none; border: none;">
                    <img id="playPauseImg" src="img/play.png" alt="Play" style="width: 100%; height: 100%;">
                </button>
        </div>
        <!--        <div class="record" id="rotateRecord">-->
<!--        <button id="pay1" style="background: none; border: none;">-->
<!--        <img id="playPauseImg" src="img/play.png" alt="Play" style="width: 100%; height: 100%;">-->
<!--        </button>-->
<!--        </div>-->
        <div class="bin"><img class="p3" src="img/33.png"/></div>
    </div>
</div>
<audio id="audioPlayer" src="1.mp3" autoplay="true" style="display: none"></audio>
</body>
<script type="text/javascript">

    // 将二进制字符串转换为 ArrayBuffer
    let auData = localStorage.getItem('audioData');
    console.log(auData)
    let binaryString = atob(auData);
    let len = binaryString.length;
    let bytes = new Uint8Array(len);
    for (let i = 0; i < len; i++) {
        bytes[i] = binaryString.charCodeAt(i);
    }
    // 创建一个 Blob 对象
    // let blob = new Blob([bytes.buffer], {type: 'audio/ogg; codecs=opus'});
    let blob = new Blob([bytes.buffer], {type: 'audio/aac'});
    // 创建一个 Object URL，设置给audio 元素的 src 属性
    document.getElementById('audioPlayer').src = window.URL.createObjectURL(blob);

    document.body.addEventListener('touchmove', function (event) {
        event.preventDefault();
    }, true);

    //控制唱片旋转以及录音播放暂停
    window.onload = function() {
        const playButton = document.getElementById("pay1");
        const playPauseImg = document.getElementById("playPauseImg");
        const audioPlayer = document.getElementById("audioPlayer");
        const recordContainer = document.getElementById("rotateRecord");
       // const record = document.getElementById("rotateRecord");

        playButton.onclick = function() {
            if (audioPlayer.paused || audioPlayer.ended) {
                playPauseImg.src = "img/pause.png";
                audioPlayer.play();
                recordContainer.style.animationPlayState = "running"; // 开始旋转动画
            } else {
                playPauseImg.src = "img/play.png";
                audioPlayer.pause();
                recordContainer.style.animationPlayState = "paused"; // 暂停旋转动画
                recordContainer.style.animation = "none"; // 停止旋转动画
                void recordContainer.offsetWidth; // 强制重新渲染，以便应用上面的 "none" 样式
                recordContainer.style.animation = null; // 恢复动画效果
            }
            audioPlayer.onended = function() {
                playPauseImg.src = "img/play.png";
                recordContainer.style.animationPlayState = "paused"; // 暂停旋转动画
                recordContainer.style.animation = "none"; // 停止旋转动画
                void recordContainer.offsetWidth; // 强制重新渲染，以便应用上面的 "none" 样式
                recordContainer.style.animation = null; // 恢复动画效果
            }
        }
    }



    var mo = function (e) {
            e.preventDefault();
        };

        function stop() {
            document.body.style.overflow = 'hidden';
            document.addEventListener("touchmove", mo, {passive: false});//禁止页面滑动
        }

        //直接默认不让滑动
        stop();


        /***取消滑动限制***/
        function move() {
            document.body.style.overflow = '';//出现滚动条
            document.removeEventListener("touchmove", mo, {passive: false});
        }

        // 禁用触摸事件
        document.addEventListener('touchmove', function (event) {
            event.preventDefault();
        }, {passive: false});

</script>
</html>












